Skip to content

block: fix infinite loop in badblocks_clear()#770

Open
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1085681=>linus-master
Open

block: fix infinite loop in badblocks_clear()#770
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1085681=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Apr 26, 2026

Pull request for series with
subject: block: fix infinite loop in badblocks_clear()
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1085681

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 26, 2026

Upstream branch: dd6c438
series: https://patchwork.kernel.org/project/linux-block/list/?series=1085681
version: 1

An infinite loop can occur in _badblocks_clear() when BB_OFFSET(p[prev + 1])
equals bad.start, resulting in len = 0. This causes the update_sectors loop
to spin forever without making progress:

    s += 0;         // no advancement
    sectors -= 0;   // stays positive
    goto re_clear;  // infinite loop

The bug exists in two code paths:
1. _badblocks_clear() at line 1153 (behind overlap check)
2. _badblocks_check() at line 1240 (behind overlap check)

Add checks in both functions to ensure len is non-zero before entering
the loop.

Signed-off-by: Ramesh Adhikari <[email protected]>
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 26, 2026

Upstream branch: dd6c438
series: https://patchwork.kernel.org/project/linux-block/list/?series=1085693
version: 2

@blktests-ci blktests-ci Bot added V2 and removed V1 labels Apr 26, 2026
@blktests-ci blktests-ci Bot force-pushed the series/1085681=>linus-master branch from 02d2577 to b27d89c Compare April 26, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant